package com.xt.mvcpilot.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.xt.mvcpilot.data.Role;


/**
 * Role validator
 * 
 * @author txiao
 *
 */
public class RoleValidator implements Validator{
	
	public boolean supports(Class clazz) {
	   //just validate the Permission instances
	   return Role.class.isAssignableFrom(clazz);
	}

	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "role.validator.name.required");
	}
}
